<!DOCTYPE HTML>
<html>
	<head>

		<title>TradingView Charting Library demo</title>

		<!-- Fix for iOS Safari zooming bug -->
		<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0">
		<meta http-equiv="X-UA-Compatible" content="IE=Edge">

		<script type="text/javascript" src="charting_library/charting_library.min.js"></script>
		<script type="text/javascript" src="datafeeds/udf/dist/bundle.js?v=8"></script>

		<script type="text/javascript">
	
			window.ws = new WebSocket("ws://47.105.49.33:8090");

			/*
				id规则
				ping: 0
				getBars: 10
				subscribeBars: 20
				unsubscribeBars: 30
			*/
      window.WSInterval = setInterval(() => {
        if (window.ws && window.ws.readyState === 1) {
					try {
						const params = {"method":"server.ping","params":["BTC/USDT"],"id":0};
						window.ws.send(JSON.stringify(params));
					} catch(e) {
						console.error(`WSInterval has error: ${e}`)
					}
        }
      }, 1000 * 10);
			function getParameterByName(name) {
				name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
				var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
					results = regex.exec(location.search);
				return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
			}

			TradingView.onready(function()
			{
				var widget = window.tvWidget = new TradingView.widget({
					debug: true, // uncomment this line to see Library errors and warnings in the console
					fullscreen: true,
					symbol: 'BTC/USDT',
					interval: '1',    //默认显示
					container_id: "tv_chart_container",

					timezone: 'Asia/Shanghai',
					//	BEWARE: no trailing slash is expected in feed URL
					datafeed: new Datafeeds.UDFCompatibleDatafeed(),
					library_path: "charting_library/",
					locale: "zh",
					theme: 'Dark',
					favorites: {
						intervals: ['1', '5', '15', '30', '60', '1D', '7D']
					},
					disabled_features: [
						'header_symbol_search',
						'symbol_search_hot_key',
						'header_compare',
						'header_undo_redo',
						'header_screenshot',
						'timeframes_toolbar',
						'context_menus',
						'volume_force_overlay'
					],
      		enabled_features: [
						'hide_last_na_study_output',
						'keep_left_toolbar_visible_on_small_screens',
						'hide_left_toolbar_by_default',
						'move_logo_to_main_pane',
						'adaptive_logo'
					],
				});
			});

		</script>

	</head>

	<body style="margin:0px;">
		<div id="tv_chart_container"></div>
	</body>

</html>
